import { z } from 'zod'

import { baseManyObjectsScheme, baseSchemeWithNote } from '@/types/base.types'

export const assemblyStatuses: { [index: number]: string } = {
	0: 'Не согласована',
	1: 'Согласована',
	9: 'Произведена'
}

export const assemblyScheme = baseSchemeWithNote.extend({
	address: z.string(),
	date: z.coerce.date(),
	end_date: z.coerce.date().nullable(),
	status: z.number().min(0).max(9),
	cost: z.number(),
	paid: z.boolean(),
	claim: z.string(),
	worker_note: z.string(),
	order: z.number(),
	worker: z.number(),
	attachs: z.number()
})

export type IAssembly = z.infer<typeof assemblyScheme>

export const assembliesScheme = baseManyObjectsScheme.extend({
	results: z.array(assemblyScheme)
})

export type IAssemblies = z.infer<typeof assembliesScheme>
